package com.aplink.generic.pojo.controlspec;

import com.aplink.generic.constant.type.EditTextType;
import com.aplink.generic.pojo.controlspec.textview.DisplayStyle;
import com.aplink.generic.util.validation.Validation;

public class EditTextSpec extends ControlSpec {
	public static final int MAX_LENGTH = 255;
	public static final int MIN_LENGTH = 0;
	private static final long serialVersionUID = -6224071544358646342L;
	private boolean isReadOnly;
	private boolean isSearch;
	private boolean isSingleLine;
	private EditTextType mDataInputType;
	private String mDigist;
	private String mHint;
	private int mMaxLength;
	private int mMinLength;
	private String mRegex;
	private String mSearchControl;
	private String mSearchField;
	private String mText;
	private Validation mValidation;

	public EditTextSpec() {

	}

	private String mDisplayFormat;
	private String mDisplayType;

	public String getDisplayFormat() {
		return this.mDisplayFormat;
	}

	public DisplayStyle getDisplayStyle() {
		return DisplayStyle.get(this.mDisplayType);
	}

	public String getDisplayType() {
		return this.mDisplayType;
	}

	public void setDisplayFormat(final String displayFormat) {
		this.mDisplayFormat = displayFormat;
	}

	public void setDisplayType(final String displayType) {
		this.mDisplayType = displayType;
	}

	public EditTextSpec(final boolean isReadOnly, final boolean isSearch,
			final Validation validation, final EditTextType dataInputType,
			final String searchControl, final String searchField,
			final int minLength, final int maxLength, final String regex) {
		this.isReadOnly = isReadOnly;
		this.isSearch = isSearch;
		this.mDataInputType = dataInputType;
		this.mSearchControl = searchControl;
		this.mSearchField = searchField;
		this.mMinLength = minLength;
		this.mMaxLength = maxLength;
		this.mValidation = validation;
		setRegex(regex);
	}

	/**
	 * The input type of EditText in Android.<br/>
	 * This property mapping for "inputtype" attribute.<br/>
	 * Example: inputtype="text"
	 * 
	 * @return DataInputType
	 */
	public EditTextType getDataInputType() {
		return this.mDataInputType;
	}

	public String getDigist() {
		return mDigist;
	}

	public String getHint() {
		return mHint;
	}

	public int getMaxLength() {
		return this.mMaxLength;
	}

	public int getMinLength() {
		return this.mMinLength;
	}

	public String getRegex() {
		return mRegex;
	}

	public String getRegularExpression() {
		return this.mRegex;
	}

	public String getSearchControl() {
		return this.mSearchControl;
	}

	public String getSearchField() {
		return this.mSearchField;
	}

	public String getText() {
		return mText;
	}

	public Validation getValidation() {
		return this.mValidation;
	}

	/**
	 * The rule to set EditText just read only.<br/>
	 * This property mapping for "readonly" element. Example: <readonly/>
	 * 
	 * @return True or False.
	 */
	public boolean isReadOnly() {
		return this.isReadOnly;
	}

	public boolean isSearch() {
		return this.isSearch;
	}

	public boolean isSingleLine() {
		return isSingleLine;
	}

	/**
	 * The input type of EditText in Android.<br/>
	 * This property mapping for "inputtype" attribute.<br/>
	 * Example: inputtype="text"
	 * 
	 * @param dataInputType
	 */
	public void setDataInputType(final EditTextType dataInputType) {
		this.mDataInputType = dataInputType;
	}

	/**
	 * The input type of EditText in Android.<br/>
	 * This property mapping for "inputtype" attribute.<br/>
	 * Example: inputtype="text"
	 * 
	 * @param dataInputTypeName
	 */
	public void setDataInputType(final String dataInputTypeName) {
		this.mDataInputType = EditTextType.get(dataInputTypeName);
	}

	public void setDigist(String digist) {
		mDigist = digist;
	}

	public void setHint(String hint) {
		mHint = hint;
	}

	public void setMaxLength(final int maxLength) {
		this.mMaxLength = maxLength;
	}

	public void setMinLength(final int minLength) {
		this.mMinLength = minLength;
	}

	/**
	 * The rule to set EditText just read only.<br/>
	 * This property mapping for "readonly" element. Example: <readonly/>
	 * 
	 * @param isReadOnly
	 */
	public void setReadOnly(final boolean isReadOnly) {
		this.isReadOnly = isReadOnly;
	}

	public void setRegex(final String regex) {
		this.mRegex = regex;
	}

	public void setSearch(final boolean isSearch) {
		this.isSearch = isSearch;
	}

	public void setSearchControl(final String searchControl) {
		this.mSearchControl = searchControl;
	}

	public void setSearchField(final String searchField) {
		this.mSearchField = searchField;
	}

	public void setSingleLine(boolean isSingleLine) {
		this.isSingleLine = isSingleLine;
	}

	public void setText(String text) {
		mText = text;
	}

	public void setValidation(final Validation validation) {
		this.mValidation = validation;
	}

}
